﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Charities.ModelViews;
using CharitiesLib;

namespace Charities.Forms
{
    public partial class EmptyWorthyReport : Form
    {
        public EmptyWorthyReport(Form m)
        {
            fo = m;
            this.MdiParent = m;
            InitializeComponent();
        }
        public bool is_loaded = false;
        Form fo = null;
        ModelContainer ctx = new ModelContainer();
        private void Form1_Load(object sender, EventArgs e)
        {
            PersonVM pvm = new PersonVM();
            if (ctx.CharityInfos.Count() > 0)
            {
              CharityInfoBindingSource.DataSource = ctx.CharityInfos.First();
            }
            else
            {
                MessageBox.Show("يجب تنصيب الاعدادات الرئيسية حتى تعمل التقارير بالشكل الامثل ","تنويه",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
            PersonVMBindingSource.DataSource = pvm;
            this.reportViewer2.RefreshReport();
            
        }
        public byte[] imageToByteArray(System.Drawing.Image imageIn)
        {
            MemoryStream ms = new MemoryStream();
            imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            return ms.ToArray();
        }

        private void GrantsReport_FormClosed(object sender, FormClosedEventArgs e)
        {
            is_loaded = false;
            // remove this form from windows list
            ((Forms.FormMDI)fo).removeFormFromWindowsList(this);
        }

        private void GrantsReport_Activated(object sender, EventArgs e)
        {
            // activate this form and add it windows list as activate one
            ((Forms.FormMDI)this.MdiParent).activateWindow(this);
        }
    }
}
